#ifndef AST_EXPRESSION_ADDITIVE_EXPR_H
#define AST_EXPRESSION_ADDITIVE_EXPR_H

#include "../ASTNode.h"

class MultiplicativeExpr;
/*
C99 6.5.6
additive-expression:
		multiplicative-expression
		additive-expression    +    multiplicative-expression
		additive-expression    -    multiplicative-expression
*/
class AdditiveExpr : public ASTNode
{
public:
	enum{
		single_expr,
		add_expr,
		sub_expr,
	};
protected:
	AdditiveExpr(void)
		: ASTNode(ASTNode::additive_expression){};
public:
	explicit AdditiveExpr(MultiplicativeExpr *pSingleExpr)
		: ASTNode(ASTNode::additive_expression)
		, m_iType(single_expr)
		, m_pSingleExpr(pSingleExpr){};
	AdditiveExpr(MultiplicativeExpr *pMulExpr, char cOp, AdditiveExpr * pAddExpr)
		: ASTNode(ASTNode::additive_expression)
		, m_pMulExpr(pMulExpr)
		, m_pAddExpr(pAddExpr)
		, m_cOp(cOp)
	{
		if(cOp == '+') m_iType = add_expr;
		else if(cOp == '-') m_iType = sub_expr;
	}
	virtual ~AdditiveExpr(void);

	virtual void						codeGen();
protected:
	tiny_int							m_iType;
	union{
	MultiplicativeExpr *				m_pSingleExpr;
	struct{
	AdditiveExpr *						m_pAddExpr;
	char								m_cOp;
	MultiplicativeExpr *				m_pMulExpr;
	};
	};
};


#endif

